<?php defined('SYSPATH') or die('No direct script access.');
//header('Refresh: 15');
class Controller_Stream extends Controller_DefaultTemplate {
	
	public function action_index() {
		$view 						= 	new View('stream');
		$model_message 				= 	new Model_Message;
		$tweets						= 	array();
		$scripts					=	array('assets/js/tweetStream.js');
		
		$this->template->title 		= 	'Stream';
		$this->template->content 	=	$view;
		$this->template->pageTitle	=	'Stream';
		$this->template->scripts	= 	array_merge($this->template->scripts, $scripts);
		
		$view->bind("tweets", $tweets);
	}
	
	public function action_gettweets(){
		$model_message 				= new Model_Message;
		
		$parameters = array();
		
		if(isset($_GET['keywords'])) {
		
			$parameters 				= explode(" ", $_GET['keywords']);
		}
		
		$tweets						= $model_message->getTwitterStream($parameters);
		
		$this->auto_render 			= false;
		
		echo json_encode($tweets);
	}
}